//
//  orderViewController.m
//  spotrs
//
//  Created by xu on 16/5/16.
//  Copyright © 2016年 TZ. All rights reserved.
//

#import "orderViewController.h"
#import "orderView.h"
@interface orderViewController ()
{
    UIButton *oneBtn;
    UIButton *twoBtn;
    UILabel *oneLine;
    UILabel *twoLine;
}
@end

@implementation orderViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.titleText= @"场馆预定";
    [self creatMainView];
     [self creatTopNavagaiong];
}
-(void)creatMainView
{
    oneBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, navagationgHright, SCREEN_WIDTH/2, 50)];
    [oneBtn setTag:1001];
    [oneBtn setBackgroundColor:RGBCOLOR(4, 63, 8)];
    [oneBtn setTitle:@"场馆预定" forState:UIControlStateNormal];
    [oneBtn setSelected:YES];
    [oneBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [oneBtn setTitleColor:[UIColor yellowColor] forState:UIControlStateSelected];
    [oneBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:oneBtn];
    
    oneLine = [[UILabel alloc] initWithFrame:CGRectMake(0, 49, SCREEN_WIDTH/2, 2)];
    [oneLine setBackgroundColor:[UIColor yellowColor]];
    [oneBtn addSubview:oneLine];
    
    
    
    twoBtn = [[UIButton alloc] initWithFrame:CGRectMake(SCREEN_WIDTH/2, navagationgHright, SCREEN_WIDTH/2, 50)];
    [twoBtn setTag:1002];
    [twoBtn setBackgroundColor:RGBCOLOR(4, 63, 8)];
    [twoBtn setTitle:@"教练预订" forState:UIControlStateNormal];
    [twoBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [twoBtn setTitleColor:[UIColor yellowColor] forState:UIControlStateSelected];
    [twoBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
    [self.view addSubview:twoBtn];
    
    twoLine = [[UILabel alloc] initWithFrame:CGRectMake(0, 49, SCREEN_WIDTH/2, 2)];
    [twoLine setBackgroundColor:RGBCOLOR(4, 63, 8)];
    [twoBtn addSubview:twoLine];
    
    _mainScroll = [[UIScrollView alloc]  initWithFrame:CGRectMake(0, navagationgHright+50+1, SCREEN_WIDTH, SCREEN_HEIGHT-navagationgHright-50-toolbarHright)];
    [_mainScroll setDelegate:self];
    [_mainScroll setPagingEnabled:YES];
    [_mainScroll setContentSize:CGSizeMake(SCREEN_WIDTH*2, 0)];
    [self.view addSubview:_mainScroll];
   
    orderView *oneOrder = [[orderView alloc] initWithFrame:CGRectMake(0, 0, SCREEN_WIDTH, _mainScroll.frame.size.height)array:nil];
    [_mainScroll addSubview:oneOrder];
    
    orderView *twoOrder = [[orderView alloc] initWithFrame:CGRectMake(SCREEN_WIDTH, 0, SCREEN_WIDTH, _mainScroll.frame.size.height)array:nil];
    [_mainScroll addSubview:twoOrder];
    
}
-(void)btnClick:(UIButton*)sender
{
    switch (sender.tag) {
        case 1001:
        {
            [oneBtn setSelected:YES];
            [twoBtn setSelected:NO];
            [oneLine setBackgroundColor:[UIColor yellowColor]];
            [twoLine setBackgroundColor:RGBCOLOR(4, 63, 8)];
        }
            break;
        case 1002:
        {
            [oneBtn setSelected:NO];
            [twoBtn setSelected:YES];
            [twoLine setBackgroundColor:[UIColor yellowColor]];
            [oneLine setBackgroundColor:RGBCOLOR(4, 63, 8)];
        }
            break;
        default:
            break;
    }
}
- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView
{
    int index = scrollView.contentOffset.x/SCREEN_WIDTH;
    if (index == 0) {
        [oneBtn setSelected:YES];
        [twoBtn setSelected:NO];
        [oneLine setBackgroundColor:[UIColor yellowColor]];
        [twoLine setBackgroundColor:RGBCOLOR(4, 63, 8)];
    }
    else
    {
        [oneBtn setSelected:NO];
        [twoBtn setSelected:YES];
        [twoLine setBackgroundColor:[UIColor yellowColor]];
        [oneLine setBackgroundColor:RGBCOLOR(4, 63, 8)];    }
   
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
